﻿@using System.Web.Optimization
@using StackExchange.Opserver.Models
@using StackExchange.Opserver.Views.Shared
@using StackExchange.Profiling
@{
    var topNodes = ViewData[ViewDataKeys.TopBoxOptions] as TopBoxOptions;
}
<!DOCTYPE html>
<html>
<head>
    <title>@Html.Raw((string)ViewData[ViewDataKeys.PageTitle])</title>
    <meta name="viewport" content="width=device-width">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="stylesheet" href="@HtmlUtils.CacheBreaker("~/Content/themes/" + Theme.Current + "/styles.min.css")">
    <link href="@HtmlUtils.CacheBreaker("~/Content/img/apple-touch-icon.png")" rel="apple-touch-icon"/>
    <script src="@HtmlUtils.CacheBreaker("~/Content/js/jquery-1.11.3.min.js")"></script>
    @Scripts.Render("~/scripts/plugins.js")    @Scripts.Render("~/scripts/scripts.js")    <script>
        $(function() {
            Status.init({ SiteName: '@SiteSettings.SiteName', Tab:'@TopTabs.CurrentTab', rootPath: '@Url.Content("~/")', HeaderRefresh: 15 });
            @if (topNodes?.AllNodes?.Any() ?? false)
            {
                var serverJson = topNodes.AllNodes.Select(n => new
                    {
                        label = n.DisplayName,
                        value = n.Name,
                        icon = n.MonitorStatus.TextClass(showGood: true),
                        category = n.CategoryName
                    }).OrderBy(n => n.category).ThenBy(n => n.label);
                @:Status.NodeSearch.init({ nodes: @Json.Encode(serverJson).AsHtml() });
            }
        });
    </script>    @RenderSection("head", false)    @MiniProfiler.Current.RenderIncludes()
</head>
<body>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#topbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="~/hub"></a>
            </div>

            <div class="collapse navbar-collapse" id="topbar-collapse">
                @Html.Partial("IssuesButton")
                @if (topNodes?.SearchOnly ?? false)
                {
                    <form action="@topNodes.Url" method="GET" class="navbar-form navbar-left" role="search">
                        <div class="form-group-sm">
                            <input type="text" class="form-control js-filter" placeholder="查询@(topNodes.SearchText.HasValue() ? " " + topNodes.SearchText : "")..." value="@topNodes.SearchValue" name="@topNodes.QueryParam" />
                        </div>
                        @if (topNodes.SearchParams != null)
                        {
                            foreach (var p in topNodes.SearchParams)
                            {
                                <input type="hidden" name="@p.Key" value="@p.Value" />
                            }
                        }
                    </form>
                }
                else if (topNodes?.AllNodes?.Any() ?? false)
                {
                    var s = topNodes.CurrentNode;
                    <form action="@topNodes.Url" method="GET" class="navbar-form navbar-left" role="search">
                        <div class="form-group-sm">
                            <input type="text" class="form-control js-filter@(s != null ? " left-icon " + s.MonitorStatus.TextClass() : "")" placeholder="Search@(topNodes.SearchText.HasValue() ? " " + topNodes.SearchText : "")..." value="@(s?.DisplayName)" name="node" />
                        </div>
                    </form>
                }
                @Html.Partial("~/Views/Shared/TopTabs.cshtml")
            </div>
        </div>
    </nav>
<div class="container-fluid js-content">
    @RenderBody()
</div>
</body>
</html>
